<template>
	<view class="container">
		<view class="tui-page-title">骑手端</view>
		<form @submit="formSubmit" @reset="">
			<view class="tui-form">
				<view class="tui-view-input">
					<tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
						<view class="tui-cell-input">
							<tui-icon name="mobile" color="#6d7a87" :size="20"></tui-icon>
							<input
								placeholder-class="tui-phcolor"
								:value="mobile"
								@input="inputMobile"
								class="tui-input"
								name="mobile"
								placeholder="请输入手机号"
								maxlength="11"
								type="number"
							/>
							<view class="tui-icon-close" v-show="mobile" @tap="clearInput(1)"><tui-icon name="close-fill" :size="16" color="#bfbfbf"></tui-icon></view>
						</view>
					</tui-list-cell>
					<tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
						<view class="tui-cell-input">
							<tui-icon name="pwd" color="#6d7a87" :size="20"></tui-icon>
							<input
								placeholder-class="tui-phcolor"
								:value="password"
								@input="inputPwd"
								class="tui-input"
								name="pwd"
								placeholder="请输入密码"
								maxlength="20"
								type="password"
							/>
							<view class="tui-icon-close" v-show="password" @tap="clearInput(2)"><tui-icon name="close-fill" :size="16" color="#bfbfbf"></tui-icon></view>
						</view>
					</tui-list-cell>
				</view>
				<view class="tui-btn-box">
					<tui-button :disabledGray="true" :disabled="disabled" formType="submit" :shadow="true" shape="circle">登录</tui-button>
				</view>
			</view>
		</form>
	</view>
</template>

<script>
	const form = require("@/components/common/tui-validation/tui-validation.js")
	export default {
		computed: {
			disabled: function() {
				let bool = true;
				if (this.mobile && this.password) {
					bool = false;
				}
				return bool;
			}
		},
		data() {
			return {
				mobile: '',
				password: ''
			};
		},
		methods: {
			inputMobile: function(e) {
				this.mobile = e.detail.value;
			},
			inputPwd: function(e) {
				this.password = e.detail.value;
			},
			formSubmit: function(e) {
				//表单规则
				let that = this;
				let param = e.detail.value;
				let rules = [{
					name: "mobile",
					rule: ["required", "isMobile"],
					msg: ["请输入手机号", "请输入正确的手机号"]
				}, {
					name: "pwd",
					rule: ["required", "isEnAndNo"],
					msg: ["请输入密码", "密码为8~20位数字和字母组合"]
				}];
				//进行表单检查
				let formData = e.detail.value;
				console.log("formData=="+formData)
				let checkRes = form.validation(formData, rules);
				if (!checkRes) {
					let that = this
					that.$u.api.riderLogin(param).then(data => {
						console.log(1)
						uni.navigateTo({
							url: '../horseman/horseman'
						})
					})
				} else {
					uni.showToast({
						title: checkRes,
						icon: "none"
					});
				}
			}
		}
	}
</script>

<style lang="scss">
	.container {
		// .tui-status-bar {
		// 	width: 100%;
		// 	height: var(--status-bar-height);
		// }
	
		.tui-header {
			width: 100%;
			padding: 40rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			box-sizing: border-box;
		}
	
		.tui-page-title {
			width: 100%;
			font-size: 48rpx;
			font-weight: bold;
			color: $uni-text-color;
			line-height: 42rpx;
			padding: 40rpx;
			box-sizing: border-box;
		}
	
		.tui-form {
			padding-top: 50rpx;
	
			.tui-view-input {
				width: 100%;
				box-sizing: border-box;
				padding: 0 40rpx;
	
				.tui-cell-input {
					width: 100%;
					display: flex;
					align-items: center;
					padding-top: 48rpx;
					padding-bottom: $uni-spacing-col-base;
	
					input {
						flex: 1;
						padding-left: $uni-spacing-row-base;
					}
	
					.tui-icon-close {
						margin-left: auto;
					}
				}
			}
	
			.tui-cell-text {
				width: 100%;
				padding: $uni-spacing-col-lg $uni-spacing-row-lg;
				box-sizing: border-box;
				font-size: $uni-font-size-sm;
				color: $uni-text-color-grey;
				display: flex;
				align-items: center;
				justify-content: space-between;
	
				.tui-color-primary {
					color: $uni-color-primary;
				}
			}
	
			.tui-btn-box {
				width: 100%;
				padding: 0 $uni-spacing-row-lg;
				box-sizing: border-box;
				margin-top: 80rpx;
			}
		}
	
		.tui-login-way {
			width: 100%;
			font-size: 26rpx;
			color: $uni-color-primary;
			display: flex;
			justify-content: center;
			position: fixed;
			left: 0;
			bottom: 80rpx;
	
			view {
				padding: 12rpx 0;
			}
		}
	
		.tui-auth-login {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			padding-bottom: 80rpx;
			padding-top: 20rpx;
	
			.tui-icon-platform {
				width: 90rpx;
				height: 90rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				position: relative;
				margin-left: 40rpx;
	
				&::after {
					content: '';
					position: absolute;
					width: 200%;
					height: 200%;
					transform-origin: 0 0;
					transform: scale(0.5, 0.5) translateZ(0);
					box-sizing: border-box;
					left: 0;
					top: 0;
					border-radius: 180rpx;
					border: 1rpx solid $uni-text-color-placeholder;
				}
			}
	
			.tui-login-logo {
				width: 60rpx;
				height: 60rpx;
			}
		}
	}
</style>
